package com.darren.befriend.fragments;

import java.util.ArrayList;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.View;

import com.darren.befriend.BaseActivity;
import com.darren.befriend.HomeActivity;
import com.darren.befriend.R;
import com.darren.befriend.UserSettingInitialActivity;
import com.darren.befriend.constants.Constant;
import com.parse.ParseObject;

public class FriendForFragment extends HobbyBaseFragment {

	public static Fragment create() {

		FriendForFragment fragment = new FriendForFragment();
		return fragment;
	}

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		interestTextArr = getResources().getStringArray(R.array.friend_for);
		mInterestResIds = new int[] { R.drawable.hob0, R.drawable.hob1,
				R.drawable.hob2, R.drawable.hob3, R.drawable.hob4,
				R.drawable.hob5, R.drawable.hob6, R.drawable.hob7,
				R.drawable.hob8 };
	}

	@SuppressWarnings("unchecked")
	@Override
	public void onActivityCreated(Bundle savedInstanceState) {
		// if (getActivity() instanceof HomeActivity) {

		mCurrentUser = ((BaseActivity) getActivity()).getCurrentUser();
		if (mCurrentUser != null) {

			ParseObject meInfor = (ParseObject) mCurrentUser.get("MeInfo");
			if (meInfor != null) {

				try {

					mSelected = (ArrayList<Boolean>) meInfor.get("Hobby");
				} catch (Exception ex) {

				}
			}
		}
		// }

		super.onActivityCreated(savedInstanceState);
		mTitle = getString(R.string.a_friend_for);
		if (getActivity() instanceof UserSettingInitialActivity) {

			((UserSettingInitialActivity) getActivity())
					.setActivityTitle(mTitle);
			((UserSettingInitialActivity) getActivity()).setNavigationImage(
					R.drawable.item_back, Integer.MAX_VALUE);
		} else if (getActivity() instanceof HomeActivity) {

			((HomeActivity) getActivity()).setActivityTitle(mTitle);
			((HomeActivity) getActivity()).showRightButtonImg(false);
			((HomeActivity) getActivity()).setLeftImage(R.drawable.item_back);
		}
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see android.support.v4.app.Fragment#onPause()
	 */
	@Override
	public void onPause() {
		// TODO Auto-generated method stub
		super.onPause();
	}

	@Override
	public void onClick(View v) {

		HOBBY_TYPE = Constant.HOBBY;
		super.onClick(v);
	}

}
